import { GlobalFunction } from "../base/GlobalFunction";

const {ccclass, property} = cc._decorator;

@ccclass
export default class updateSwordDir extends cc.Component {

    @property(cc.Node)
    modelBody:cc.Node = null;

    update(dt){
        var dir = this.node.getComponent(cc.RigidBody).linearVelocity;
        if(dir.equals(cc.v2(0,0)) || !GlobalFunction.getWorldMgr().getAttackMode())
            this.modelBody.getComponent("modelBase").setRotation(0,0,-90);
        else
            this.modelBody.getComponent("modelBase").setDirection(GlobalFunction.getDirection(dir));
    }
}
